﻿/*-------------------------------------------------------------------------
 * CLR版本:     4.0.30319.42000
 * 创建人:      song
 * 创建时间：   2024/4/9 14:47:37
 * 功 能：      SCore入口 ==> SetUp ==> BindSComponent ==> BindAssetManager ==> Init
 *                        ==> Game Runing  ==> Clear ==> GameEnding
 *-------------------------------------------------------------------------*/

using System.Collections.Generic;
using Function.Preferences;
using Function.RedPoint;
using SCore.Function.ScriptPipeline;
using SCore.Function.Touch;
using SCore.Util;

namespace SCore.Core
{
    public class SCoreMain
    {
        private static readonly List<IComponent> Coms = new List<IComponent>(); //管理组件
        public static readonly EventManager EventManager = new EventManager(); //事件
        public static Touch _touch = new Touch();
        public static ScriptPipelineSystem _scriptPipelineSystem = new ScriptPipelineSystem();

        //配置
        public static void SetUp()
        {
            CoRoutineExecutors.Init(); //co
            PlayerPref.Init(); //pref
            BindSComponent(_touch); //touch
            BindSComponent(_scriptPipelineSystem); //spipeline
            BindSComponent(RedPointSystem.Instance); //red
        }

        public static void BindSComponent(IComponent component)
        {
            Coms.Add(component);
        }


        public static void Init()
        {
            foreach (var com in Coms)
            {
                com.Init();
            }
        }

        public static void Clear()
        {
            foreach (var com in Coms)
            {
                com.Clear();
            }
        }
    }
}